class Masteries(object):
    def __init__(self,parent):
        self.Masteries={}
        self.parent=parent
        self.InitMasteriesLimitList()
        self.InitOffensiveMasteriesList()
        self.InitDefensiveMasteriesList()
        self.InitUtilityMasteriesList()

    def SetMasteries(self,mastery):
        self.Masteries=mastery

    def InitMasteriesLimitList(self):
        self.MasteriesLimitList={}
        self.MasteriesLimitList["SummonersWrath"]=1
        self.MasteriesLimitList["BruteForce"]=3
        self.MasteriesLimitList["MentalForce"]=4
        self.MasteriesLimitList["Butcher"]=2
        self.MasteriesLimitList["Alacrity"]=4
        self.MasteriesLimitList["Sorcery"]=4
        self.MasteriesLimitList["Demolitionist"]=1
        self.MasteriesLimitList["Deadliness"]=4
        self.MasteriesLimitList["WeaponsExpertise"]=1
        self.MasteriesLimitList["ArcaneKnowledge"]=1
        self.MasteriesLimitList["Havoc"]=3
        self.MasteriesLimitList["Lethality"]=1
        self.MasteriesLimitList["Vampirism"]=3
        self.MasteriesLimitList["Blast"]=4
        self.MasteriesLimitList["Sunder"]=3
        self.MasteriesLimitList["Archmage"]=4
        self.MasteriesLimitList["Executioner"]=1
        self.MasteriesLimitList["SummonersResolve"]=1
        self.MasteriesLimitList["Resistance"]=3
        self.MasteriesLimitList["Hardiness"]=3
        self.MasteriesLimitList["ToughSkin"]=2
        self.MasteriesLimitList["Durability"]=4
        self.MasteriesLimitList["Vigor"]=3
        self.MasteriesLimitList["Indomitable"]=2
        self.MasteriesLimitList["VeteransScars"]=1
        self.MasteriesLimitList["Evasion"]=3
        self.MasteriesLimitList["BladedArmor"]=1
        self.MasteriesLimitList["SiegeCommander"]=1
        self.MasteriesLimitList["Initiator"]=3
        self.MasteriesLimitList["Enlightenment"]=3
        self.MasteriesLimitList["HonorGuard"]=3
        self.MasteriesLimitList["Mercenary"]=3
        self.MasteriesLimitList["Juggernaut"]=1
        self.MasteriesLimitList["SummonersInsight"]=1
        self.MasteriesLimitList["GoodHands"]=3
        self.MasteriesLimitList["ExpandedMind"]=3
        self.MasteriesLimitList["ImprovedRecall"]=1
        self.MasteriesLimitList["Swiftness"]=4
        self.MasteriesLimitList["Meditation"]=3
        self.MasteriesLimitList["Scout"]=1
        self.MasteriesLimitList["Greed"]=4
        self.MasteriesLimitList["Transmutation"]=3
        self.MasteriesLimitList["RunicAffinity"]=1
        self.MasteriesLimitList["Wealth"]=2
        self.MasteriesLimitList["Awareness"]=4
        self.MasteriesLimitList["Sage"]=1
        self.MasteriesLimitList["StrengthOfSpirit"]=3
        self.MasteriesLimitList["Intelligence"]=3
        self.MasteriesLimitList["Mastermind"]=1

    def InitOffensiveMasteriesList(self):
        self.OffensiveMasteriesList=[]
        self.OffensiveMasteriesList.append('SummonersWrath')
        self.OffensiveMasteriesList.append('BruteForce')
        self.OffensiveMasteriesList.append('MentalForce')
        self.OffensiveMasteriesList.append('Butcher')
        self.OffensiveMasteriesList.append('Alacrity')
        self.OffensiveMasteriesList.append('Sorcery')
        self.OffensiveMasteriesList.append('Demolitionist')
        self.OffensiveMasteriesList.append('Deadliness')
        self.OffensiveMasteriesList.append('WeaponsExpertise')
        self.OffensiveMasteriesList.append('ArcaneKnowledge')
        self.OffensiveMasteriesList.append('Havoc')
        self.OffensiveMasteriesList.append('Lethality')
        self.OffensiveMasteriesList.append('Vampirism')
        self.OffensiveMasteriesList.append('Blast')
        self.OffensiveMasteriesList.append('Sunder')
        self.OffensiveMasteriesList.append('Archmage')
        self.OffensiveMasteriesList.append('Executioner')

    def InitDefensiveMasteriesList(self):
        self.DefensiveMasteriesList=[]
        self.DefensiveMasteriesList.append('SummonersResolve')
        self.DefensiveMasteriesList.append('Resistance')
        self.DefensiveMasteriesList.append('Hardiness')
        self.DefensiveMasteriesList.append('ToughSkin')
        self.DefensiveMasteriesList.append('Durability')
        self.DefensiveMasteriesList.append('Vigor')
        self.DefensiveMasteriesList.append('Indomitable')
        self.DefensiveMasteriesList.append('VeteransScars')
        self.DefensiveMasteriesList.append('Evasion')
        self.DefensiveMasteriesList.append('BladedArmor')
        self.DefensiveMasteriesList.append('SiegeCommander')
        self.DefensiveMasteriesList.append('Initiator')
        self.DefensiveMasteriesList.append('Enlightenment')
        self.DefensiveMasteriesList.append('HonorGuard')
        self.DefensiveMasteriesList.append('Mercenary')
        self.DefensiveMasteriesList.append('Juggernaut')

    def InitUtilityMasteriesList(self):
        self.UtilityMasteriesList=[]
        self.UtilityMasteriesList.append('SummonersInsight')
        self.UtilityMasteriesList.append('GoodHands')
        self.UtilityMasteriesList.append('ExpandedMind')
        self.UtilityMasteriesList.append('ImprovedRecall')
        self.UtilityMasteriesList.append('Swiftness')
        self.UtilityMasteriesList.append('Meditation')
        self.UtilityMasteriesList.append('Scout')
        self.UtilityMasteriesList.append('Greed')
        self.UtilityMasteriesList.append('Transmutation')
        self.UtilityMasteriesList.append('RunicAffinity')
        self.UtilityMasteriesList.append('Wealth')
        self.UtilityMasteriesList.append('Awareness')
        self.UtilityMasteriesList.append('Sage')
        self.UtilityMasteriesList.append('StrengthOfSpirit')
        self.UtilityMasteriesList.append('Intelligence')
        self.UtilityMasteriesList.append('Mastermind')
        
    def UpdateStats(self,parent):
        for key,value in parent.Masteries.iteritems():
            if key == "SummonersWrath" and value == "1":
                parent.SummonersWrath=True
            if key == "BruteForce":
                parent.Attack_Damage += int(value)
            if key == "MentalForce":
                parent.Ability_Power += int(value)
            if key == "Butcher":
                parent.ExtraMinionDamage += int(value)*2
            if key == "Alacrity":
                parent.Attack_Speed_Percentage += int(value)
            if key == "Sorcery":
                parent.Cooldown_Reduction += int(value)
            if key == "Demolitionist" and value == "1":
                parent.Demolitionist = True
            if key == "Deadliness":
                parent.Attack_Damage += (0.125 * float(value))*parent.Level
            if key == "WeaponsExpertise":
                parent.Armor_Penetration_Percentage += 10.0
            if key == "ArcaneKnowledge":
                parent.Magic_Penetration_Percentage += 10.0
            if key == "Havoc":
                parent.Physical_Damage_Percentage += (0.5 * float(value))
                parent.Magical_Damage_Percentage += (0.5 * float(value))
            if key == "Lethality":
                parent.Critical_Strike_Chance += 10.0
            if key == "Vampirism":
                parent.Life_Steal += float(value)
            if key == "Blast":
                parent.Ability_Power += (0.25 * float(value))*parent.Level
            if key == "Sunder":
                parent.Armor_Penetration_Flat += 2*int(value)
            if key == "Archmage":
                parent.Ability_Power_Percentage += 1.25 *float(value)
            if key == "Executioner":
                parent.Executioner=True
            # defensive
            if key == "SummonersResolve" and value == "1":
                parent.SummonersResolve=True
            if key == "Resistance":
                parent.Magic_Resist += 2*int(value)
            if key == "Hardiness":
                parent.Armor += 2*int(value)
            if key == "ToughSkin":
                parent.ToughSkin = int(value)
            if key == "Durability":
                parent.Health += (1.5 * float(value)) * parent.Level
            if key == "Vigor":
                parent.Health_Regen_per_5_seconds += int(value)
            if key == "Indomitable":
                parent.Indomitable= int(value)
            if key == "VeteransScars":
                parent.Health += 30
            if key == "Evasion":
                parent.Evasion=int(value)
            if key == "BladedArmor" and value == "1":
                parent.BladedArmor=True
            if key == "SiegeCommander" and value == "1":
                parent.SiegeCommander=True
            if key == "Initiator":
                parent.Initiator = int(value)
            if key == "Enlightenment":
                parent.Cooldown_Reduction += (0.15 * float(value)) * parent.Level
            if key == "HonorGuard":
                parent.HonorGuard = (0.5 * float(value))
            if key == "Mercenary":
                pass
            if key == "Juggernaut":
                parent.Juggernaut = True
                parent.Health_Percentage += 3
            # utility
            if key == "SummonersInsight" and value == '1':
                parent.SummonersInsight=True
            if key == "GoodHands":
                pass
            if key == "ExpandedMind":
                parent.Mana += (4 * int(value)) * parent.Level
                # da gehoert noch engery dazu
                # On champions that use energy, increases energy by 4 / 7 / 10.
            if key == "ImprovedRecall":
                pass
            if key == "Swiftness":
                parent.Movement_Speed_Percentage += 0.5 * float(value)
            if key == "Meditation":
                parent.Mana_Regen_per_5_seconds += int(value)
            if key == "Scout":
                pass
            if key == "Greed":
                pass
            if key == "Transmutation":
                parent.Spell_Vamp += int(value)
            if key == "RunicAffinity":
                pass
                # buff +20%
            if key == "Wealth":
                pass
            if key == "Awareness":
                pass
            if key == "Sage":
                pass
            if key == "StrengthOfSpirit":
                parent.Health_Regen_per_5_seconds += ((0.1 + (0.3*float(value)))/100) * parent.Mana
            if key == "Intelligence":
                parent.Cooldown_Reduction += 2*int(value)
            if key == "Mastermind":
                parent.Mastermind = True